package test.enba.redis.service;

import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

@Service
public class CacheService {

  @Cacheable(value = "user", key = "#id")
  public String getUserById(Long id) {
    // 模拟从数据库查询
    System.out.println("Querying database for user with id: " + id);
    return "User " + id;
  }

  @CacheEvict(value = "user", key = "#id")
  public void deleteUserById(Long id) {
    System.out.println("Deleting user with id: " + id);
  }
}
